#include "stdafx.h"
#include <boost/test/auto_unit_test.hpp>
#include "bmock.hpp"

static int f(int x, int& y, int* z) {
	MOCK(3,(IN(x),IN_OUT(y),IN_OUT(z)));
	return 1;
}

struct in_out_arguments2 {
	in_out_arguments2()
		:y_actual(y_in)
		,z_actual(z_in)
		,r_actual(0)
		,y_expected(bmock::in_out_raw_mem(y_in,y_out))
		,z_expected(bmock::in_out_raw_mem(z_in,z_out))
	{
		BMOCK_CREATE_MOCK(*);
		BOOST_CHECK_NO_THROW(BMOCK_EXPECT_RETURN(r,f(x,y_expected,z_expected)));
		BMOCK_REPLAY;
		BOOST_CHECK_NO_THROW(r_actual = f(x,y_actual,&z_actual));
		BMOCK_VERIFY;
	}
	static const int x     = 25;
	static const int y_in  = 39;
	static const int y_out = 139;
	static const int z_in  = 57;
	static const int z_out = 157;
	static const int r     = 197;

	int                       y_actual;
	int                       z_actual;
	int                       r_actual;
	bmock::in_out_raw_mem_descr<int> y_expected;
	bmock::in_out_raw_mem_descr<int> z_expected;
};

const int in_out_arguments2::x;
const int in_out_arguments2::y_in;
const int in_out_arguments2::y_out;
const int in_out_arguments2::z_in;
const int in_out_arguments2::z_out;
const int in_out_arguments2::r;



BMOCK_TEST(in_out_arguments2,test_return_value) {
	BOOST_CHECK_EQUAL(r,r_actual);
}

BMOCK_TEST(in_out_arguments2,test_reference_argument) {
	BOOST_CHECK_EQUAL(y_out,y_actual);
}

BMOCK_TEST(in_out_arguments2,test_pointer_argument) {
	BOOST_CHECK_EQUAL(z_out,z_actual);
}
